import type PageModal from '@/components/page-modal/page-modal.vue'
import { ref } from 'vue'
function usePageModal(newCallback?: any, editCallback?: any) {
  const modelRef = ref<InstanceType<typeof PageModal>>()
  function handleNewClick() {
    // 新建
    modelRef.value?.setDialogVisible(true)
    if (newCallback) {
      newCallback()
    }
  }
  function handleEditClick(itemData: any) {
    // 编辑
    modelRef.value?.setDialogVisible(false, itemData)
    // console.log({ ...itemData })
    if (editCallback) {
      editCallback(itemData)
    }
  }
  return {
    modelRef,
    handleNewClick,
    handleEditClick
  }
}
export default usePageModal
